# Database

Rig uses a postgres database to store its data. This article explains how to configure it.

When installing the rig helm chart the value `postgres.enabled` toggles a small
single instance postgres. This is only meant for development environments and
not production. For production environments we recommend that you use a managed
database at your cloud provider, or another for of production ready database.

The `rig-platform` container will at startup connect to the database, and print
any error there may be if wrongly configured.

To connect rig to your own database please follow the steps below.

## Postgres

To connect to your own PostgreSQL database, you need to fill out the following
section of your helm values:

```yaml title="Helm values - Platform"
rig:
  client:
    postgres:
      host: <host-and-port>
      user: <username>
      password: <password>
      insecure: <set to true if insecure>
      database: rig
```

### Database migrations

The postgres implementation uses Schema Migrations to ensure consistent upgrades to newer schemas.
This is done automatically when `rig-platform` is starting.

:::info
If you end up having to wipe the database, it's thus important that you also wipe the `schema_migrations` table:

```sql
DROP TABLE schema_migrations;
```
:::
